package com.ssy.lingxi.purchase.controller.online;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.purchase.api.dto.request.BaseDetailsRequest;
import com.ssy.lingxi.purchase.api.dto.request.bidding.BiddingListRequest;
import com.ssy.lingxi.purchase.api.dto.request.bidding.BiddingProductRequest;
import com.ssy.lingxi.purchase.api.dto.request.online.OnlineSignUpRequest;
import com.ssy.lingxi.purchase.api.dto.request.online.SubmitReportPriceRequest;
import com.ssy.lingxi.purchase.api.dto.response.BiddingExternalWorkStateEnumResponse;
import com.ssy.lingxi.purchase.api.dto.response.bidding.*;
import com.ssy.lingxi.purchase.api.dto.response.online.OnlineBiddingDetailsResponse;
import com.ssy.lingxi.purchase.service.online.OnlineBiddinService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @menu 采购能力 - 在线竞价
 * @author wrc
 * @version 2.0.0
 * @date 2021/03/23
 */
@RestController
@RequestMapping("/purchase/online/bidding")
public class OnlineBiddingController  extends BaseController {


    @Resource
    OnlineBiddinService onlineBiddinService;

    /**
     *采购竞价单查询
     */
    @GetMapping("/list")
    public Wrapper<PageData<BiddingListResponse>> biddingList(BiddingListRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return onlineBiddinService.biddingList(request,sysUser);
    }

    /**
     *采购竞价单详情
     */
    @GetMapping("/details")
    public Wrapper<OnLineBiddingDetailsResponse> biddingDetails(BaseDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return onlineBiddinService.biddingDetails(request,sysUser);
    }

    /**
     *采购物料分页查询
     */
    @GetMapping("/materiel/page")
    public  Wrapper<PageData<BiddingProductRequest>>  materielPage(BaseDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return onlineBiddinService.materielPage(request,sysUser);
    }

    /**
     *采购竞价单详情-最低报价记录 使用竞价单ID查询
     */
    @GetMapping("/minimum/bidding")
    public Wrapper<PageData<AwardProcessDetailsResponse>> minimumBidding(@Validated BaseDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return onlineBiddinService.minimumBidding(request,sysUser);
    }

    /**
     *采购竞价单详情-授标结果 使用竞价单ID查询
     */
    @GetMapping("/award/results/bidding")
    public Wrapper<PageData<AwardProcessDetailsResponse>> awardResultsBidding(@Validated BaseDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return onlineBiddinService.awardResultsBidding(request,sysUser);
    }

    /**
     *采购竞价单详情-查询竞价过程
     */
    @GetMapping("/process")
    public Wrapper<List<AwardProcessResponse>> process(BaseDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return onlineBiddinService.process(request,sysUser);
    }

    /**
     *待竞价报名列表
     */
    @GetMapping("/stay/examine/bidding/signup")
    public Wrapper<PageData<BiddingListResponse>> stayExamineBiddingSignup(BiddingListRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return onlineBiddinService.stayExamineBiddingSignup(request,sysUser);
    }

    /**
     *竞价报名
     */
    @PostMapping("/online/signup")
    public Wrapper<Void> onlineSignUp(@Validated @RequestBody OnlineSignUpRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return onlineBiddinService.onlineSignUp(request,sysUser);
    }

    /**
     *待竞价列表
     */
    @GetMapping("/stay/bidding/list")
    public Wrapper<PageData<BiddingListResponse>> stayBiddingList(BiddingListRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return onlineBiddinService.stayBiddingList(request,sysUser);
    }

    /**
     *待竞价-竞价
     */
    @GetMapping("/bidding/details")
    public Wrapper<OnlineBiddingDetailsResponse> stayBiddingDetails(BaseDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return onlineBiddinService.stayBiddingDetails(request,sysUser);
    }

    /**
     *竞价-提交报价
     */
    @PostMapping("/submit/report/price")
    public Wrapper<Void> submitReportPrice(@Validated @RequestBody  SubmitReportPriceRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return onlineBiddinService.submitReportPrice(request,sysUser);
    }

    /**
     * 获取采购报价单内部流程状态
     */
    @GetMapping("/interior/status")
    public Wrapper<List<BiddingExternalWorkStateEnumResponse>> interiorStatus() {
        return onlineBiddinService.interiorStatus();
    }

    /**
     * 获取采购竞价单外部流程状态
     */
    @GetMapping("/external/status")
    public Wrapper<List<BiddingExternalWorkStateEnumResponse>> externalStatus() {
        return onlineBiddinService.externalStatus();
    }
}
